<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/jstl.jsp" %>
<script language="javascript">
function check(){
    var isCheck = getById("notall_0").checked;
    var sMsg    = "结束时间不能小于开始时间！";
    if(isCheck){
        //时间
        var sDate1 = getById("mydatea").value;
        var sDate2 = getById("mydateb").value;
            sDate1 = sDate1.replace("-" ,"").replace("-" ,"");
            sDate2 = sDate2.replace("-" ,"").replace("-" ,"");
        if(sDate1 > sDate2){
            alertMsg.info(sMsg);
            getById("mydateb").focus();
            return false;
        }
    }
    
    var fLimitMinAmt     = idTextToNumber("LIMIT_MIN_AMT"    ),//单笔最小金额
        fLimitMaxAmt     = idTextToNumber("LIMIT_MAX_AMT"    ),//单笔最大金额
        fLimitDayTimes   = idTextToNumber("LIMIT_DAY_TIMES"  ),//限制日交易次数
        fLimitDayAmt     = idTextToNumber("LIMIT_DAY_AMT"    ),//限制日交易金额
        fLimitMonthTimes = idTextToNumber("LIMIT_MONTH_TIMES"),//限制月交易次数
        fLimitMonthAmt   = idTextToNumber("LIMIT_MONTH_AMT"  ),//限制月交易金额
        fLimitYearTimes  = idTextToNumber("LIMIT_YEAR_TIMES" ),//限制年交易次数
        fLimitYearAmt    = idTextToNumber("LIMIT_YEAR_AMT"   );//限制年交易金额
    
    sMsg = "单笔最小金额不能大于单笔最大金额！";
    if(fLimitMinAmt > fLimitMaxAmt){
        alertMsg.info(sMsg);
        getById("LIMIT_MAX_AMT").focus();
        return false;
    }
    
    sMsg = "每日交易限额不能大于每日交易次数*单笔最大限额！";
    if(fLimitDayTimes!="" && fLimitDayAmt!="") {
        if(fLimitDayAmt > fLimitMaxAmt*fLimitDayTimes){
            alertMsg.info(sMsg); 
            getById("LIMIT_DAY_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每月交易限额不能大于每月交易次数*单笔最大限额！";
    if(fLimitMonthTimes!="" && fLimitMonthAmt!="") {
        if(fLimitMonthAmt > fLimitMaxAmt*fLimitMonthTimes){
            alertMsg.info(sMsg);
            getById("LIMIT_MONTH_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每月交易次数不能小于每日交易次数！";
    if(fLimitDayTimes!="" && fLimitMonthTimes!=""){
        if(fLimitMonthTimes < fLimitDayTimes){
            alertMsg.info(sMsg);
            getById("LIMIT_MONTH_TIMES").focus();
            return false;
        }
    }
    
    sMsg = "每日交易金额不能小于单笔最大金额！";
    if(fLimitDayAmt!="") {
        if(fLimitDayAmt < parseFloat(slimitmaxamt)){
            alertMsg.info(sMsg);
            getById("LIMIT_DAY_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每月交易金额不能小于单笔最大金额！";
    if(fLimitMonthAmt!="") {
        if(fLimitMonthAmt < fLimitMaxAmt){
            alertMsg.info(sMsg);
            getById("LIMIT_MONTH_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每月交易金额不能小于每日交易金额！";
    if(fLimitDayAmt!="" && fLimitMonthAmt!="") {
        if(fLimitMonthAmt < fLimitDayAmt){
            alertMsg.info(sMsg);
            getById("LIMIT_MONTH_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每年交易金额不能小于单笔最大金额";
    if(fLimitYearAmt!=""){
        if(fLimitYearAmt<fLimitMaxAmt){
            alertMsg.info(sMsg);
            getById("LIMIT_YEAR_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每年交易金额不能小于每月交易金额";
    if(fLimitYearAmt!="" && fLimitMonthAmt){
        if(fLimitYearAmt<fLimitMonthAmt){
            alertMsg.info(sMsg);
            getById("LIMIT_YEAR_AMT").focus();
            return false;
        }
    }
    
    sMsg = "每年交易限额不能大于每年交易次数*单笔最大限额！";
    if(fLimitYearAmt!="" && fLimitYearTimes){
        if(fLimitYearAmt > fLimitYearTimes*fLimitMaxAmt){
            alertMsg.info(sMsg);
            getById("LIMIT_YEAR_AMT").focus();
            return false;
        }
    }
    
    return true;        
}

function getById(id){
    return document.getElementById(id);
}

function idTextToNumber(id){
    var sText = getById(id).value;
    if(sText == ""){
        return sText;
    }else{
        return parseFloat(sText);
    }
}

function checkNums(obj){
    //obj.value = obj.value.replace(/[^\d.]/g,"");
    ///obj.value = obj.value.replace(/^\./g,"");
    //obj.value = obj.value.replace(/\.{2,}/g,".");
    //obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	if(!IdentityCodeValid(obj.value)){
		alertMsg.info("证件格式错误！");
	}
}
        
function chooseDate(){
    document.getElementById("mydatea").style.display = "block";
    document.getElementById("mydateb").style.display = "block";
    document.getElementById("indate" ).style.display = "block";
    document.getElementById("mydatea").className     = 'required textInput';
    document.getElementById("mydateb").className     = 'required textInput';                
}

function chooseDate1(){                
    document.getElementById("mydatea").style.display ="none";
    document.getElementById("mydateb").style.display ="none";
    document.getElementById("indate").style.display  ="none";
    document.getElementById("mydatea").className     ="";
    document.getElementById("mydateb").className     ="";
}

function chooseType(obj){
    if(obj == '3'){
        // 可输
        document.getElementById('aaa').disabled=false;
        //增加class 必输
        document.getElementById('aaa').className='required textInput';
    }else{
        document.getElementById('aaa').value=''
        document.getElementById('aaa').disabled=true;
        document.getElementById('aaa').className='';
    }        
}

function IdentityCodeValid(code) { 
	var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
	//var tip = "";
	var pass= true;
	
	if(!code || !/^\d{6}(18|19|20|21)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
		//tip = "身份证号格式错误";
		pass = false;
	}
	
   else if(!city[code.substr(0,2)]){
		//tip = "地址编码错误";
		pass = false;
	}
	else if(false){
		//18位身份证需要验证最后一位校验位
		if(code.length == 18){
			code = code.split('');
			//∑(ai×Wi)(mod 11)
			//加权因子
			var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
			//校验位
			var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
			var sum = 0;
			var ai = 0;
			var wi = 0;
			for (var i = 0; i < 17; i++)
			{
				ai = code[i];
				wi = factor[i];
				sum += ai * wi;
			}
			var last = parity[sum % 11];
			if(parity[sum % 11] != code[17]){
				//tip = "校验位错误";
				pass =false;
			}
		}
	}
	//if(!pass) alert(tip);
	return pass;
}
</script>
<h2 class="contentTitle" style="background-color:#E8F1FD;">添加用户限额</h2>
<div class="pageContent" style="background-color:#E8F1FD;">    
    <form  method="post" action="540244.tran" onsubmit="navTab.reloadFlag('540240.tran');return validateCallback(this, navTabAjaxDone)" class="pageForm required-validate">
        
        <input    type="hidden"    name="LIMIT_RISK_FLAG"  value="0" />
        <div class="pageFormContent" layoutH="87"  > 
            <!--用户状态类型是否显示，1:显示 0;不显示 -->
            <c:if test="${ETF.IS_SHOW_LIMIT_USER_TYPE != '0'}">
                <table  border="0" width="900px">
                    <tr height="30px">
                        <td width="16%">用户状态类型：</td>
                        <td>
                            <table>
                                <tr>
                                    <td><input id="all"     type="radio"    name="LIMIT_USER_TYPE"  value="1" onclick="chooseType(this.value);" checked />实名</td>
                                    <td><input id="all"     type="radio"    name="LIMIT_USER_TYPE"  value="2" onclick="chooseType(this.value);" />非实名</td>
                                    <td><input id="notall"  type="radio"    name="LIMIT_USER_TYPE"  value="3" onclick="chooseType(this.value);" />指定证件</td>
                                    <td><input id="aaa"     type="text"     name="LIMIT_PAPER_CODE"  size="18" maxlength="18" onblur="checkNums(this)" disabled /></td>
                               </tr>
                           </table>
                       </td>
                   </tr>
                </table>
            </c:if>

            <!--用户业务类型及支付方式是否显示，1:显示 0;不显示 -->
            <!--用户交易类型及支付方式是否显示-->
            <table  border="0" width="900px">
                <tr height="35px">
                    <td width="16%">请选择交易类型：</td>
                    <td>
                        <select name="TRAN_TYPE" id="TRANTYPE">
                            <option value="0" selected="selected">0-其他</option>
                            <option value="1">1-充值</option>
                            <option value="2">2-消费</option>
                            
                            <option value="6">6-转账(虚拟账户)</option>
                            <option value="7">7-提现</option>
                            <option value="8">8-退款</option>
                        </select>
                    </td>
                </tr>
                <tr height="30px">
                    <td width="16%">请选择支付方式：</td>
                    <td>
                        <select id="PARENT_CODE" name="PARENT_CODE">
                            <option value="00" selected="selected">00-全部</option>
                            <option value="01">01-网银</option>
                          <!--  <option value="02">02-终端</option>-->
                            <option value="03">03-消费卡</option>
                            <option value="04">04-虚拟账户</option>
                            <option value="05">05-快捷支付</option>
                        </select>
                    </td>
                </tr>
            </table>
            <c:if test="${ETF.IS_SHOW_LIMIT_BUS_CODE == '0'}">
                 <input id="opeTypeId"          type="hidden"  /> 
                 <input id="LIMIT_BUS_CLIENT"   type="hidden"  /> 
            </c:if>
            <table  border="0" width="900px"  >
                <tr height="30px">
                    <td>限额生效时间范围 ：</td>
                    <td colspan="3">
                        <table>
                            <tr>                             
                                <td>
                                    <input id="all_0" type="radio" name="LIMIT_START_TYPE" onclick="chooseDate1();" value="0" checked />永久
                                </td>
                                <td>
                                    <input id="notall_0" type="radio" name="LIMIT_START_TYPE" onclick="chooseDate();" value="1" />按交易时间
                                </td>
                                <td>
                                    <input id="mydatea" name="LIMIT_START_DATE" style="display: none" type="text"  class="date" yearstart="-80" yearend="5" readonly="true" format="yyyy-MM-dd" size="10" />
                                    <span  id="indate" class="info" style="display: none">~~</span>
                                    <input id="mydateb" name="LIMIT_END_DATE" style="display: none" type="text"  class="date" yearstart="-80" yearend="5" readonly="true" format="yyyy-MM-dd" size="10" />
                                </td>               
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr height="30px">
                    <td>单笔最小金额：</td>
                    <td>
                        <input type="text" id="LIMIT_MIN_AMT" name="LIMIT_MIN_AMT" value="0" size="30"  max="99999999999.99"  min="0" maxLength="14" class="required number"/>
                        <span class="info">（单位元）</span>
                    </td>
                    <td>单笔最大金额：</td>
                    <td>
                        <input type="text" id="LIMIT_MAX_AMT" name="LIMIT_MAX_AMT" value="0" size="30"  max="99999999999.99"  min="0" maxLength="14" class="required number"/>
                        <span class="info">（单位元）</span>
                    </td>
                </tr>
                <tr height="30px">
                    <td>每日交易次数：</td>
                    <td>
                        <input type="text" id="LIMIT_DAY_TIMES"  name="LIMIT_DAY_TIMES"  value="${ETF.LIMIT_DAY_TIMES}"  size="30" maxLength="10" min="1" class="digits" />    
                        <span class="info">（单位次）</span>
                    </td>
                    <td>每日交易限额：</td>
                    <td>
                        <input type="text" id="LIMIT_DAY_AMT"  name="LIMIT_DAY_AMT" value="0"   class="required number" size="30" max="99999999999.99"  min="0" maxLength="14"  class="number" /> 
                        <span class="info">（单位元）</span>
                    </td>
                </tr>
                <tr height="30px">
                    <td>每月交易次数：</td>
                    <td>
                        <input type="text" id="LIMIT_MONTH_TIMES" name="LIMIT_MONTH_TIMES" value="${ETF.LIMIT_MONTH_TIMES}" size="30" min="1" maxLength="10"  class="digits"/>    
                        <span class="info">（单位次）</span>
                    </td>
                    <td>每月交易限额：</td>
                    <td><input type="text" id="LIMIT_MONTH_AMT"  name="LIMIT_MONTH_AMT" 
                            value="<c:if test="${ETF.LIMIT_MONTH_AMT!=null}"><fmt:formatNumber type='currency' value='${ETF.LIMIT_MONTH_AMT/100}' pattern='0.00'/></c:if>" 
                            size="30" maxLength="14"  max="99999999999.99"  min="0" class="number" />
                        <span class="info">（单位元）</span>
                    </td>
                </tr>
                <tr height="30px">
                    <td>每年交易次数：</td>
                    <td>
                        <input type="text" id="LIMIT_YEAR_TIMES" name="LIMIT_YEAR_TIMES" value="${ETF.LIMIT_YEAR_TIMES}" size="30" min="1" maxLength="10"  class="digits"/>    
                        <span class="info">（单位次）</span>
                    </td>
                    <td>每年交易限额：</td>
                    <td><input type="text" id="LIMIT_YEAR_AMT"  name="LIMIT_YEAR_AMT" 
                            value="<c:if test="${ETF.LIMIT_YEAR_AMT!=null}"><fmt:formatNumber type='currency' value='${ETF.LIMIT_YEAR_AMT/100}' pattern='0.00'/></c:if>" 
                            size="30" maxLength="14"  max="99999999999.99"  min="0" class="number" />
                        <span class="info">（单位元）</span>
                    </td>
                </tr>
                <tr height="30px">
                    <td>启用标志：</td>
                    <td colspan="3">
                        <input type="radio" name="IS_USE" value="1" checked>启用</input>
                        <input type="radio" name="IS_USE" value="0" >未启用</input>
                    </td>
                </tr>
                <tr height="30px">
                    <td>备注：</td>
                    <td colspan="3">
                        <textarea name="LIMIT_ADDINFO" cols="60" rows="5"  maxlength="400" >${ETF.LIMIT_ADDINFO}</textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div class="formBar">
            <ul>     
                <li><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="return check();">保存</button></div></div></li>
                <li><div class="button"><div class="buttonContent"><button type="reset">重置</button></div></div></li>
                <li><div class="buttonActive"><div class="buttonContent"><button type="button" class="close" >返回</button></div></div></li>
            </ul>
        </div>
    </form>    
</div>